import socket
import cv2 as cv
import numpy as np
import os
import shutil
import easygui as a

redlower = np.array([0, 43, 46])
redupper = np.array([10, 255, 255])
bluelower = np.array([100, 43, 46])
blueupper = np.array([124, 255, 255])
greenlower = np.array([37, 43, 46])
greenupper = np.array([77, 255, 255])
img = cv.imread(r"./pics/pic" + str(i) + ".jpg", 1)
hsv = cv.cvtColor(img, cv.COLOR_BGR2HSV)
maskG = cv.inRange(hsv, lowerb=greenlower, upperb=greenupper)
maskR = cv.inRange(hsv, lowerb=redlower, upperb=redupper)
maskRG = cv.bitwise_or(maskG, maskR)
picpro = cv.bitwise_or(img, img, mask=maskG)
out = cv.GaussianBlur(picpro, (3, 3), 1.3)  # σ较大，则生成的模板的各个系数相差就不是很大，比较类似均值模板，对图像的平滑效果比较明显。
cv.imshow('videopro', out)
cv.imshow('videorecv', img)
c = cv.waitKey(35)
if c == 27:
    break;